/**
 * Created by yanghaijin on 2018/5/12.
 */
module.exports.beforeStartup = function (app, cb) {
    // do some operations before application start up
    console.log('connector beforeStartup');
    cb();
};

module.exports.afterStartup = function (app, cb) {
    // do some operations after application start up
    console.log('connector afterStartup');
    cb();

};

module.exports.beforeShutdown = function (app, cb) {
    // do some operations before application shutdown down
    console.log('connector beforeShutdown');
    cb();
};

module.exports.afterStartAll = function (app) {
    // do some operations after all applications start up
    var DB_URL = 'mongodb://localhost:27017/chm';
    // var DB_URL = 'mongodb://localhost/root/data/db';
    var DB_NAME = 'chess';

    let RoomIdGenerator = require('./../../util/RoomIdGenerator');
    RoomIdGenerator.generateRoomIdArr();

    var mongo = require('./../../util/MongoDBUtil');
    mongo.connectMongoDB(DB_URL, DB_NAME);
    app.mongo = mongo;
    app.id2mapid = {}; // 房间id转map_id

    app.roomid2mapid = {};// 房间id转map_id

    app.uid2roomid = {}; // 玩家uid转房间ID

    app.mapid2remote = {};// map_id转远程路由信息

    console.log('connector afterStartAll');
};